import socketserver

class MyServer(socketserver.BaseRequestHandler): # 继承的类固定的


    def handle(self):  # 必须是这个handle名字.

        while 1:

            from_client_data = self.request.recv(1024).decode('utf-8')  # self.request == conn管道
            print(from_client_data)

            to_client_data = input('>>>').strip()
            self.request.send(to_client_data.encode('utf-8'))



if __name__ == '__main__':

    ip_port = ('127.0.0.1',8848)
    server = socketserver.ThreadingTCPServer(ip_port,MyServer)
    # server.allow_reuse_address = True
    # print(socketserver.ThreadingTCPServer.mro())
    # [ThreadingTCPServer, ThreadingMixIn,TCPServer, BaseServer]
    server.serve_forever()

    # 1. 入口点:ThreadingTCPServer()